<?php

$dsn = 'mysql:dbname=MyBlog;host=192.168.76.11';
$user = 'root';
$password = '123456';
try {
	$dbh = new PDO($dsn, $user, $password);
} catch (PDOException $e) {
	echo 'Connection failed: ' . $e->getMessage();
}

$sql="SELECT * FROM tb_classes";

$statement = $dbh->query($sql);
if($statement === false ){
	die('SQL出错'.$dbh->errorInfo()[2]);
}
$rs_classes = $statement->fetchAll(PDO::FETCH_ASSOC);


?>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"
"http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>编辑页面</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<link rel="stylesheet" type="text/css" href="style.css" />
</head>

<body>
	<div id="header">
		<ul id="menu">
			<li><a href="index.php"><img src="images/but1.gif" alt="" width="64" height="42" /></a></li>
			<li><a href="index.php"><img src="images/but2.gif" alt="" width="108" height="42" /></a></li>
			<li><a href="index.php"><img src="images/but3.gif" alt="" width="93" height="42" /></a></li>
		</ul>
	</div>
	<div align="center">
		<form action="upload_article.php" onsubmit="publish()" method="post">
			<input type="text" placeholder="请输入文章标题"  name="title"  />
			<select name="classid">
				<?php
				foreach ($rs_classes as $KEY) {
					echo '<option value ="' . $KEY['ClassID'] . '">' . $KEY['ClassName'] . '</option>';
				}
				?>
			</select>
			<input type="hidden" name="contents" id = "contents"/>
			<button type="submit">发表文章</button>
			<p>
				<textarea rows="3" cols="43" placeholder="请输入文章摘要/简介" name="abstract"></textarea>
			</p>
		</form>
	</div>

	<?php
        include 'editor.html';
    ?>
	<script type="text/javascript">
		function publish() {
			var contents = document.getElementById('contents');
			contents.value = UE.getEditor('editor').getContent();
		}

	</script>

	<div id="footer" style="position: relative">
		<p>Copyright &copy;. All rights reserved.</p>
	</div>
</body>
</html>
